﻿using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using XYAC.Framework.MonitorTireMaterialOnline.DataExporter;
using XYAC.Framework.MonitorTireMaterialOnline.OracleRemoteDB;

namespace XYAC.Framework.MonitorTireMaterialOnline.Entities
{
    public class SemiSteelTriangleRubberReport : ReportEntityBase
    {
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public override int ID { get; set; }
        public override bool? IsDeleted { get; set; }
        public int UserId { get; set; }
        /// <summary>
        /// 补偿系数
        /// </summary>
        public double CompensationCoefficient { get; set; }
        /// <summary>
        /// 批次号
        /// </summary>
        public int BatchNo { get; set; }

        /// <summary>
        /// 规格号
        /// </summary>
        public string SpecName { get; set; }
        /// <summary>
        /// 总面积
        /// </summary>
        public double TotalArea { get; set; }

        /// <summary>
        /// 总宽标准
        /// </summary>
        public double TotalWidth_Stable { get; set; }

        /// <summary>
        /// 总宽扫描
        /// </summary>
        public double TotalWidth_Scan { get; set; }

        /// <summary>
        /// 三角胶厚度标准
        /// </summary>
        public double TotalThinkness_Stable { get; set; }

        /// <summary>
        /// 三角胶厚度标准扫描
        /// </summary>
        public double TotalThinkness_Scan { get; set; }
        /// <summary>
        /// 端点厚度
        /// </summary>
        public double TotalThinkness_Points { get; set; }

        /// <summary>
        /// 拐点厚度标准
        /// </summary>
        public double AngleThinkness_Stable { get; set; }
        /// <summary>
        /// 拐点厚度扫描
        /// </summary>
        public double AngleThinkness_Scan { get; set; }

        /// <summary>
        /// 机台编号
        /// </summary>
        public string EqpNo { get; set; }
        /// <summary>
        /// 最后同步时间
        /// </summary>
        public DateTime? LastSyncDate { get; set; }
        /// <summary>
        /// 同步状态
        /// </summary>
        public Boolean SyncState { get; set; } = false;


        /// <summary>
        /// 断面形状
        /// </summary>
        public string CrossSectionShape { get; set; }
        /// <summary>
        /// 将 SemiSteelSideInspectionReport 实例转换为 YB_PROCESS_STEP 实例。
        /// </summary>
        /// <param name="report">要转换的 SemiSteelSideInspectionReport 实例。</param>
        /// <returns>转换后的 YB_PROCESS_STEP 实例。</returns>
        public override YB_PROCESS_STEP ToYB_PROCESS_STEP()
        {
            var dataFile = DataFile.FromSpecVal(this.SpecVal);

            var processStep = new YB_PROCESS_STEP
            {
                // 映射 SemiSteelSideInspectionReport 的字段到 RECORD16 至 RECORD32
                RECORD190 = this.CompensationCoefficient.ToString(),
                PLAN_ID = this.BatchNo.ToString("F2"),
                PART_NUMBER = this.SpecName,
                RECORD160 = this.AreaPencent.ToString(),
                RECORD128 = this.TotalWidth_Stable.ToString(),
                RECORD129 = this.TotalWidth_Scan.ToString(),
                RECORD179 = this.TotalThinkness_Stable.ToString(),
                RECORD180 = this.TotalThinkness_Scan.ToString(),
                RECORD181 = this.TotalThinkness_Points.ToString(),
                RECORD182 = this.AngleThinkness_Stable.ToString(),
                RECORD183 = this.TotalThinkness_Scan.ToString(),
                RECORD164 = this.CrossSectionShape,
                RECORD159 = this.UserId.ToString(),
            };
            this.UpdateProcessStep(processStep, dataFile);
            return processStep;
        }

    }
}
